<?php
namespace App\Common\Lib\Db;

use App\Common as com;

class Where extends com\Lib\LibBase {

	/**
	 * 数组以字符串的形式转where in数组
	 * @param array $array 待转数组
	 * @return array 已转数组。格式：[ 'exp', " in ( {$inStr} )" ]
	 */
	public static function whereInStrOfArray( $array ) {
		$inStr = '';
		foreach( $array as $value ){
			if( is_numeric( $value ) ){
				$inStr .= "{$value},";
			}else{
				$inStr .= "'{$value}',";
			}
		}
		$inStr = rtrim( $inStr, ',' );
		//
		if( $inStr == '' ) $inStr = "''";
		//
		return [ 'exp', " in ( {$inStr} )" ];
	}

}
